package com.mq.retry;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ytj
 * @date 2024/1/16
 */
@Configuration
public class Demo7Config {

    @Bean
    public Queue demo7Queue() {
        /**
         * durable是否持久化
         * exclusive 是否拍它
         * autoDelete 是否自动删除
         * deadLetterExchange 死信交换机
         * deadLetterRoutingKey 死信路由键
         * */
        return QueueBuilder.durable(Demo7Message.QUEUE)
                .exclusive()
                .autoDelete()
                .deadLetterExchange(Demo7Message.EXCHANGE)
                .deadLetterRoutingKey(Demo7Message.DEAD_ROUTINGKEY)
                .build();

    }

    @Bean
    public Queue demo7DeadQueue() {
        return new Queue(Demo7Message.DEAD_QUEUE,true,false,false);
    }

    @Bean
    public DirectExchange demo7Exchange() {
        return new DirectExchange(Demo7Message.EXCHANGE,true,false);
    }

    @Bean
    public Binding demo7Binding() {
        return BindingBuilder.bind(demo7Queue()).to(demo7Exchange()).with(Demo7Message.ROUTINGKEY);
    }

    @Bean
    public Binding demo7DeadBinding() {
        return BindingBuilder.bind(demo7DeadQueue()).to(demo7Exchange()).with(Demo7Message.DEAD_ROUTINGKEY);
    }
}
